// toastr.options = {
//     "closeButton": false,
//     "debug": false,
//     "preventDuplicates": true,
//     "positionClass": "toast-top-center",
//     "onclick": null,
//     "showDuration": "400",
//     "hideDuration": "500",
//     "extendedTimeOut": "500",
//     "showEasing": "swing",
//     "hideEasing": "linear",
//     "showMethod": "fadeIn",
//     "hideMethod": "fadeOut"
// }

var toast = {
    mergeOptions: function (options) {
        const defalOptions = {
            "closeButton": false,
            "debug": false,
            "preventDuplicates": true,
            "positionClass": "toast-top-center",
            "onclick": null,
            "showDuration": "400",
            "hideDuration": "500",
            "extendedTimeOut": "500",
            "showEasing": "swing",
            "hideEasing": "linear",
            "showMethod": "fadeIn",
            "hideMethod": "fadeOut"
        };
        toastr.options = {...defalOptions, ...options};
    },
    success(title, {description = "", duration = 3000, ...restOptions}) {
        console.log(restOptions);
        this.mergeOptions(restOptions);
        return new Promise((resolve, reject) => {
            toastr.success(title,
                description, {
                    ...restOptions,
                    timeOut: duration || 3000,
                    onHidden: function () {
                        resolve();
                    }
                }
            );
        })
    },
    error(title, {description = "", duration = 3000}) {
        return new Promise((resolve, reject) => {
            toastr.error(title, description, {
                timeOut: duration || 3000,
                onHidden: function () {
                    resolve();
                }
            });
        });
    },
    warning(title, {description = "", duration = 3000}) {
        return new Promise((resolve, reject) => {
            toastr.warning(title, description, {
                timeOut: duration || 3000,
                onHidden: function () {
                    resolve();
                }
            });
        });

    },
    info(title, {description = "", duration = 3000}) {
        return new Promise((resolve, reject) => {
            toastr.info(title, description, {
                timeOut: duration || 3000,
                onHidden: function () {
                    resolve();
                }
            });
        });
    }
}
